﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Configurations;
using System.Xml.Serialization;

namespace Pixysoft.Framework.Reports
{
    public interface IReportLayout
    {
        /// <summary>
        /// 整个布局的高度
        /// </summary>
        int Height { get;set;}

        /// <summary>
        /// 整个布局的宽度
        /// </summary>
        int Width { get;set;}

        /// <summary>
        /// 布局行集合
        /// </summary>
        IReportLayoutRowCollection GetRows();

        IReportComponentCollection GetComponents();

        /// <summary>
        /// 重设宽度
        /// </summary>
        /// <param name="width"></param>
        void SetWidth(int width);

        /// <summary>
        /// 重设高度
        /// </summary>
        /// <param name="height"></param>
        void SetHeight(int height);

        /// <summary>
        /// 创建网格
        /// </summary>
        /// <param name="rowCount"></param>
        /// <param name="colCount"></param>
        void CreateGrid(int rowCount, int colCount);
    }

    //xml ignore
    public interface IReportLayoutRowCollection : IEnumerable<IReportLayoutRow>, IEnumerator<IReportLayoutRow>
    {
        IReportLayoutRow this[int index] { get; }

        IReportLayoutRow InsertRow(int rowIndex);

        IReportLayoutRow InsertRow(int rowIndex, int height);

        IReportLayoutRow AddRow(int height);

        IReportLayoutRow RemoveAt(int index);

        int Count { get;}

        /// <summary>
        /// 重新调整所有高度 包括所有行集合
        /// </summary>
        /// <param name="height"></param>
        void ResetHeight(int maxHeight);
    }

    public interface IReportLayoutRow
    {
        /// <summary>
        /// 行编号
        /// </summary>
        int RowIndex { get;set;}

        /// <summary>
        /// 绝对高度
        /// </summary>
        int Height { get;set;}

        /// <summary>
        /// 重新调整高度 包括调整行内部的所有列以及嵌套的布局
        /// </summary>
        /// <param name="height"></param>
        void SetHeight(int height);

        /// <summary>
        /// 列集合
        /// </summary>
        IReportLayoutColumnCollection GetColumns();
    }

    //xml ignore
    public interface IReportLayoutColumnCollection : IEnumerable<IReportLayoutColumn>, IEnumerator<IReportLayoutColumn>
    {
        IReportLayoutColumn this[int index] { get; }

        IReportLayoutColumn InsertColumn(int columnIndex);

        IReportLayoutColumn InsertColumn(int columnIndex, int width);

        IReportLayoutColumn AddColumn(int width);

        IReportLayoutColumn RemoveAt(int index);

        int Count { get;}

        void ResetWidth(int maxWidth);
    }

    public interface IReportLayoutColumn
    {
        /// <summary>
        /// 列编号
        /// </summary>
        int ColumnIndex { get;set;}

        /// <summary>
        /// 列宽度
        /// </summary>
        int Width { get;set;}

        /// <summary>
        /// 重设宽度 包括嵌套的布局
        /// </summary>
        /// <param name="width"></param>
        void SetWidth(int width);

        /// <summary>
        /// 包含控件的id
        /// </summary>
        string ComponentCode { get;set;}
    }

    public interface IReportComponent
    {
        string ComponentCode { get;set;}

        int FontSize { get;set;}

        string Text { get;set;}
    }

    public interface IReportComponentCollection
    {
        IReportComponent Create(string text, int fontsize);

        IReportComponent this[string componentCode] { get;}

        IReportComponent Remove(string componentCode);

        void Remove(IReportComponent component);

        void RemoveAll();
    }
}
